package com.smart;

import com.smart.common.config.spring.BeanNameAdapters;
import com.smart.common.entities.constant.SmartConstant;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import sun.misc.Unsafe;

import java.lang.reflect.Field;

/**
 * @author Administrator
 */
@EnableAsync
@SpringBootApplication
@EnableTransactionManagement
@ComponentScan(basePackages = SmartConstant.ROOT_PACKAGES, nameGenerator = BeanNameAdapters.class)
public class Application {

    public static void disableWarning() {
        try {
            Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
            theUnsafe.setAccessible(true);
            Unsafe u = (Unsafe) theUnsafe.get(null);

            Class<?> cls = Class.forName("jdk.internal.module.IllegalAccessLogger");
            Field logger = cls.getDeclaredField("logger");
            u.putObjectVolatile(cls, u.staticFieldOffset(logger), null);
        } catch (Exception e) {
            // ignore
        }
    }


    public static void main(String[] args) {
        disableWarning();
        SpringApplication.run(Application.class, args);
    }

}
